package com.lineage.server.clientpackets;

import com.lineage.echo.ClientExecutor;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1ExcludingList;
import com.lineage.server.serverpackets.S_PacketBox;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class C_Exclude extends ClientBasePacket {
  private static final Log _log = LogFactory.getLog(C_Exclude.class);
  
  public void start(byte[] decrypt, ClientExecutor client) {
    try {
      read(decrypt);
      String name = readS();
      if (name.isEmpty())
        return; 
      L1PcInstance pc = client.getActiveChar();
      L1ExcludingList exList = pc.getExcludingList();
      if (exList.isFull()) {
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(472));
        return;
      } 
      if (exList.contains(name)) {
        String temp = exList.remove(name);
        pc.sendPackets((ServerBasePacket)new S_PacketBox(19, temp));
      } else {
        exList.add(name);
        pc.sendPackets((ServerBasePacket)new S_PacketBox(18, name));
      } 
    } catch (Exception exception) {
    
    } finally {
      over();
    } 
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
